/*
 * Copyright (C) Cátedra SAES-UMU 2011 <pedromateo@um.es>
 *
 * Android HCI Extractor is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Android HCI Extractor is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.mmi.android.instrumentation.filters;

import org.mmi.android.instrumentation.BaseFilter;
import org.mmi.android.instrumentation.utils.StringUtils;
import org.mmi.facades.BaseMmiFacade;

import android.util.Log;
import android.view.View;

/**
 * Instrumentation filter for speech input.
 * 
 * @author pedro mateo (pedromateo@um.es)
 *
 */
public class SpeechInputFilter extends BaseFilter {

	private static final String TAG = "SpeechInputFilter";

	/**
	 * 
	 * @param f
	 */
	public SpeechInputFilter(BaseMmiFacade f) {
		super(f);
	}

	@Override
	public void onInteractionStart() {
	}

	@Override
	public void onInteractionEnd() {
	}

	@Override
	public void install(View v) {
		//no installation needed in this prototype
	}
	
	/// //////////////////////////////////////////////////////////
	/// //////////////////////////////////////////////////////////

	/// 
	/// filtering (redirection) methods
	///

	
	///
	///speech input 
	
	/**
	 * Handles a new utterance.
	 * @param u the utterance text
	 */
	public void onUtterance(String u){
		Log.d(TAG,"OnUtterance: " + u);
		mmim_.overallWords(0, StringUtils.countWords(u));
		mmim_.overallConcepts(0, 1);
	}
	
	/**
	 * Handles a correctly parsed utterance result.
	 */
	public void onCorrectlyParsedUtterance(){
		Log.d(TAG,"onCorrectlyParsedUtterance");
		mmim_.correctlyParsedUtterance(0);
	}
	
	/**
	 * Handles a partially correct parsed utterance result.
	 */
	public void onPartiallyParsedUtterance(){
		Log.d(TAG,"onPartiallyParsedUtterance");
		mmim_.partiallyParsedUtterance(0);
	}
	
	/**
	 * Handles an incorrect parsed utterance result.
	 */
	public void onIncorrectlyParsedUtterance(){
		Log.d(TAG,"onIncorrectlyParsedUtterance");
		mmim_.incorrectlyParsedUtterance(0);
	}
	
	///
	///speech output
	
	/**
	 * Handles an ASR reject.
	 */
	public void onASRReject(){
		Log.d(TAG,"OnASRReject");
		mmim_.isASRRejection(0);
	}
}
